import { common } from "@kit.AbilityKit";

// utils/GlobalContext.ts
export class GlobalContext {
  private static instance: GlobalContext;
  private context: common.Context | null = null;

  private constructor() {}

  static getInstance(): GlobalContext {
    if (!GlobalContext.instance) {
      GlobalContext.instance = new GlobalContext();
    }
    return GlobalContext.instance;
  }

  setContext(context: common.Context): void {
    this.context = context;
  }

  getContext(): common.Context {
    if (!this.context) {
      throw new Error('Context is not initialized!');
    }
    return this.context;
  }
}